home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / enoent.c < prev    next >
C/C++ Source or Header  |  1994-03-01  |  903b  |  47 lines

  1. #include <errno.h>
  2. #include <string.h>
  3. #include <stat.h>
  4. #include <mintbind.h>
  5. #include "lib.h"
  6.  
  7. extern int __mint;
  8.  
  9. /*
  10. Given a pathname for which some system call returned EPATH, this function
  11. decides if UNIX would have returned ENOENT instead.
  12. Warning: path must be in dos format.
  13. */
  14.  
  15. int
  16. _enoent(path)
  17.   char *path;
  18. {
  19.   register char *s;
  20.   struct stat st;
  21.   long oldmask;
  22.  
  23.   if (__mint < 9)
  24.   {
  25.     return 0; /* don't bother... */
  26.   }
  27.   for (s = path; *s; s++)
  28.     /* nop */;
  29.   oldmask = Psigblock(~0L);
  30.   for ( ; s != path; s--)
  31.   {
  32.     if (*s == '\\')
  33.     {
  34.       *s = '\0';
  35.       if ((Fxattr(0, path, &st) == 0) && ((st.st_mode & S_IFMT) != S_IFDIR))
  36.       {
  37.         *s = '\\';
  38.         (void) Psigsetmask(oldmask);
  39.         return 0; /* existing non-directory file in path, ENOTDIR ok */
  40.       }
  41.       *s = '\\';
  42.     }
  43.   }
  44.   (void) Psigsetmask(oldmask);
  45.   return 1; /* should have been ENOENT */
  46. }
  47.